<template>
	<div class="uploadimg">
		<div class="imageItem" :class="{mr0:maxCount==1}" v-for="(item,index) in imglist" :key="index">
			<u--image radius="10" :showLoading="true" :src="item" width="140rpx" height="140rpx"
				@click="previewImg(imglist,index)">
			</u--image>
		</div>
	</div>
</template>

<script>
	import configs from "@/config/config.js"
	export default {
		data() {
			return {
			}
		},
		components: {

		},
		props: {
			maxCount: {
				type: Number,
				default () {
					return 100;
				}
			},
			list: {
				type: Array,
				default () {
					return [];
				}
			}
		},
		watch: {},
		computed: {
			imglist: function() {
				var list = []
				this.list.forEach((type) => {
					list.push(configs.baseUrl + type)
				});
				return list
			}
		},
		methods: {
			// 大图预览
			previewImg(imgUrlList, index) {
				let _this = this;
				// #ifdef MP
				uni.previewImage({
					current: index,
					urls: imgUrlList,
					indicator: 'number',
					loop: true
				});
				// #endif

				// #ifndef MP
				uni.previewImage({
					current: index,
					urls: imgUrlList,
					indicator: 'number',
					loop: true
				});
				// #endif
			},
		}
	}
</script>

<style scoped lang="scss">
	.upload {
		width: 140rpx;
		height: 140rpx;
		background: #EDEDED;
		border-radius: 20rpx;
		opacity: 1;
		display: flex;
		justify-content: center;
		align-items: center;
		flex-wrap: nowrap;
		flex-direction: row;

		image {
			width: 34rpx;
		}
	}

	.uploadimg {
		display: flex;
		justify-content: flex-start;
		align-items: flex-start;
		flex-wrap: wrap;
		flex-direction: row;
		width: 532rpx;

		.imageItem {
			margin-right: 24rpx;
			width: 140rpx;
			height: 140rpx;
			position: relative;
			margin-top: 12rpx;
		}

	}

	.mr0 {
		margin-right: 0 !important;
	}
</style>
